

package JDBC;

import Entidades.*;
import FabricaConexiones.Conexion;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class Insertar {
    
    private Connection conexion = null;
    private Statement stm = null;
    private ResultSet rs = null;

    public Insertar() {
    }
    
    
    public void insertaDatosTarjetaCredito(TarjetaCredito tc){
    try {
            conexion = Conexion.obtenerConexion();
            stm = conexion.createStatement();
            rs = stm.executeQuery("INSERT INTO TARJETA_CREDITO VALUES(TARJETA_CREDITO_SEQ.NEXTVAL,"+tc.getNumeroTarjeta()+",'"+tc.getMesVigencia()+"', '"+tc.getAnioVigencia()+"', "+tc.getNumeroSeguridad()+")");
        } catch (Exception e) {
        } finally {
            try {
                conexion.close();
                stm.close();
            } catch (SQLException ex) {
                System.out.println("No se cerro correctamente la conexion ");
            }
        }
    
    }
    
    public void insertaDatosCliente(Cliente cli, long tc_id){
        try {
            conexion = Conexion.obtenerConexion();
            stm = conexion.createStatement();
            rs = stm.executeQuery("INSERT INTO CLIENTE VALUES(CLIENTE_SEQ.NEXTVAL,'"+cli.getNombre()+"', '"+cli.getApellidoPaterno()+"', '"+cli.getApellidoMaterno()+"', '"+cli.getRfc()+"', '"+cli.getEmail()+"', '"+cli.getDireccion()+"', "+tc_id+")");
        } catch (Exception e) {
        } finally {
            try {
                conexion.close();
                stm.close();
            } catch (SQLException ex) {
                System.out.println("No se cerro correctamente la conexion ");
            }
        }
    }
    
    public void insertaDatosCotizacion(Cotizacion cot, long edoRepId, long modeloId, long tipoSegId, long clienteId, long precioSegId){
            try {
            conexion = Conexion.obtenerConexion();
            stm = conexion.createStatement();
            rs = stm.executeQuery("INSERT INTO COTIZACION VALUES(COTIZACION_SEQ.NEXTVAL, SYSDATE,"+cot.getAnioAuto()+", "+cot.getCodigoPostal()+", "+cot.getEdadConductor()+", "+cot.getCostoSeguro()+", "+edoRepId+", "+modeloId+", "+tipoSegId+", "+clienteId+", "+precioSegId);
        } catch (Exception e) {
        } finally {
            try {
                conexion.close();
                stm.close();
            } catch (SQLException ex) {
                System.out.println("No se cerro correctamente la conexion ");
            }
        }
    
    
    }

    public Connection getConexion() {
        return conexion;
    }

    public void setConexion(Connection conexion) {
        this.conexion = conexion;
    }

    public Statement getStm() {
        return stm;
    }

    public void setStm(Statement stm) {
        this.stm = stm;
    }

    public ResultSet getRs() {
        return rs;
    }

    public void setRs(ResultSet rs) {
        this.rs = rs;
    }
    
    
    
}
